package com.iccct.cloud.user.controller;

import com.iccct.cloud.commons.result.OKResponse;
import com.iccct.cloud.commons.result.Response;
import com.iccct.cloud.user.model.User;
import com.iccct.cloud.user.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author iccct (taowutt1@gmail.com)
 * @since 2021-11-08  11:13
 */
@RestController
@RequestMapping("user")
public class LoginController {
    @Resource
    private UserService userService;

    @PostMapping("/login")
    public Map<String,Object> login(@RequestBody User user){
        Map<String,Object> map = new HashMap<>();
        map.put("status","200");
        map.put("token","aaaaaaaa");
        map.put("data",user);
        return map;
    }


    @GetMapping("/list")
    public Response list(){
        List<User> allUser = userService.getAllUser();
        return OKResponse.QUERY.toResponse(allUser);
    }
}
